package member.controller;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class MyPageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1. 로그인 여부 확인
		HttpSession session = request.getSession();
		Object o = session.getAttribute("login_member");
		String url = null;
		//2. 처리
		if(o!=null){
			//2-1. 로그인 했으면 /member/member_detail.jsp로 이동
			url = "/member/member_detail.jsp";
		}else{
			//2-2. 로그인을 하지 않았으면 /member/login_form.jsp로 이동
			url = "/member/login_from.jsp";
		}
		RequestDispatcher rdp = request.getRequestDispatcher(url);
		rdp.forward(request, response);
	}

}
